import request from "@/utils/request"

//加入购物车
export function addCart (params) {
    return request({
      url: '/cart/add',
      method:'POST',
      data: params
    })
  }

//删除单个
export function deleteCartById(id){
    return request({
        url:`/cart/delete/${id}`,
        method: 'DELETE',
    })
}

//清空
export function deleteCartAll(){
    return request({
        url:'/cart/clear',
        method:'DELETE'
    })
}

//查询购物车
export function getCart(params){
 return request({
    url:'/cart/list',
    method:'GET',
    params
 })
}

//更新购物车商品数量
export function updateCartQuantity(id, quantity) {
  return request({
    url: '/cart/update',
    method: 'PUT',
    params: {
      id,
      quantity
    }
  })
}